package cn.roadtrip.mtravelbusinessmodule.util.wxpay;

import com.egzosn.pay.common.api.PayService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "wx.pay")
@Slf4j
@Data
public class WxPayConfig {

    private String appId;

    private String appKey;

    private String mchId;

    private String secretKey;

    private String notifyUrl;

    private String returnUrl;

    private String signType;

    private String inputCharset;

    private String cerPath;


    @Bean
    public PayService createPayWXService(@Autowired WxPayConfig wxPayConfig) {
//        Gson gson = new Gson();
//        log.info("加载配置：{}",gson.toJson(wxPayConfig));
//        WxPayConfigStorage wxPayConfigStorage = new WxPayConfigStorage();
//        wxPayConfigStorage.setMchId(wxPayConfig.getMchId());
//        wxPayConfigStorage.setAppId(wxPayConfig.getAppId());
//
//        wxPayConfigStorage.setNotifyUrl("异步回调地址");
//        wxPayConfigStorage.setReturnUrl("同步回调地址");
//        wxPayConfigStorage.setSignType(wxPayConfig.getSignType());
//        wxPayConfigStorage.setInputCharset("utf-8");
//        return new WxPayService(wxPayConfigStorage);
        return null;
    }
}
